package com.taglab.chic.search.impl;

import com.taglab.chic.search.Query;
import com.taglab.chic.search.Hit;
import com.taglab.chic.search.SearchResults;

import java.util.List;
import java.util.LinkedList;
import java.util.Date;

/**
 * @author Markus Kobler
*/
class ResultBuilder {

  private Date created = new Date();

  private Query query;

  private List<Hit> hits = new LinkedList<Hit>();

  private int total = 0;

  ResultBuilder(Query query) {
    if( query == null) throw new NullPointerException();
    this.query = query;
  }

  public void addResult(Hit hit) {
    hits.add(hit);
  }

  public void setTotalResults(int total) {
    this.total = total;
  }

  public SearchResults createResults() {
    return new SearchResults(query, hits, total, new Date());
  }

  public Date getCreated() {
    return created;
  }

}
